<template>
<div>
  <h1>商品添加</h1>
  <P>商品名称:<input type="text" v-model="form.name"></P>
  <P>商品价格:<input type="text" v-model="form.price"></P>
  <p>
    <select name="" id="" v-model="form.cate">
    <option :value="i.id" v-for="i in catelist">{{i.name}}</option>
    </select>
  </p>
  <button @click="add">添加</button>

  <h1>商品展示</h1>
  <table border="1" cellspacing="0" align="center">
    <tr>
      <td>名称</td>
      <td>价格</td>
    </tr>
    <tr v-for="i in shoplist">
      <td>{{i.name}}</td>
      <td>{{i.price}}</td>
    </tr>
  </table>

</div>
</template>

<script>
export default {
  name: "show_shop",
  data(){
    return{
      form:{},
      catelist:{},
      shoplist:{},
    }
  },
  methods:{
    add(){
      this.$axios.post('users/showshop/',this.form)
      .then(res=>{
        console.log(res.data)
      })
    },
    get_catelist(){
      this.$axios.get('users/catem/')
      .then(res=>{
        this.catelist=res.data.list
      })
    },
    get_shoplist(){
      this.$axios.get('users/showshop/')
      .then(res=>{
        console.log(res.data)
        this.shoplist=res.data.list
      })
    },
  },
  mounted() {
    this.get_catelist()
    this.get_shoplist()
  }
}
</script>

<style scoped>

</style>
